﻿var _phone = '';
var isGetVCode = false;
var AdId = 357;
var telphone, zpcj, lgs;

var sessionid = "";
function getMRegUser(mobile, remark) {

    var regs = /^1[3|4|5|6|7|8|9]\d{9}$/;
    if (!(regs.test(mobile))) {
        layer.close(lgs);
        layer.msg("请输入正确的手机号码！");
        return false;
    }
    if (isGetVCode) {
        layer.close(lgs);
        layer.msg("请勿重复提交！");
        return false;
    } else {
        layer.closeAll();

        sendtxb();

	//提交 手机号：mobile 诊股信息：remark
        subscribeData(mobile, '', remark, function (ret) {

            sendcomplete();

            if (ret.code === 1) {

                layer.msg('提交成功，稍后会有客服人员与您联系。');
                ogeturl();//提交成功必执行

            } else {
                layer.msg(ret.msg);
            }

            layer.close(lgs);
        });


    }
}


var ogeturl = function () {
    $(".phonec").val('');
    $(".tan_div").hide();

    gdt('track', 'RESERVATION', { 'key1': 'value1', 'key2': 'value2' });

};

function checkData(data, pro, code) {
    var reg = new RegExp("^\d{6}$");
    var flag = false;
    for (var i = 0; i < data.length; i++) {
        var temp = data[i];
        if (temp[pro] == code) {
            flag = true;
            break;
        }
    }
    return flag;
}

$('.dialogBtn').on('click', function () {
    telphone = $.trim($(".phonec").val());
    zpcj = cNum;
    if (zpcj == '') {
        layer.msg('请输入正确的股票代码');
        return false;
    } else {
        gdt('track', 'REGISTER', { 'key1': 'value1', 'key2': 'value2' });
        lgs = layer.load();
        var gName = $.trim($(".gName").text());
        if (gName != "") {
            zpcj += ',' + gName;
        }
        getMRegUser(telphone, zpcj);
    }
});
